<template>
    <div>
        <div class="clearfix selector">

            <div class="type-wrap">
                <div class="fl key">房屋类型</div>
                <div class="fl value">
                    <ul class="type-list">
                        <li>
                            <a @click="searchH(0)">商品房</a>
                        </li>
                        <li>
                            <a @click="searchH(1)">公寓住宅</a>
                        </li>
                        <li>
                            <a @click="searchH(2)">单元式住宅</a>
                        </li>
                        <li>
                            <a @click="searchH(3)">复式住宅</a>
                        </li>
                    </ul>
                </div>
                <div class="fl ext"></div>
            </div>
            <div class="type-wrap">
                <div class="fl key">装修情况</div>
                <div class="fl value">
                    <ul class="type-list" v-model="decorate">
                        <li>
                            <a @click="searchD(0)">精美装修</a>
                        </li>
                        <li>
                            <a @click="searchD(1)">简单装修</a>
                        </li>
                        <li>
                            <a @click="searchD(2)">毛坯装修</a>
                        </li>
                    </ul>
                </div>
                <div class="fl ext"></div>
            </div>
        </div>
        <!-- 猜你喜欢 -->
        <div class="like">
            <div class="py-container">
                <!--details-->
                <div class="details clearfix">
                    <div class="sui-navbar">
                        <div class="navbar-inner filter">
                            <ul class="sui-nav">
                                <li class="active">
                                    <a href="#">综合</a>
                                </li>
                                <li>
                                    <a href="#">销量</a>
                                </li>
                                <li>
                                    <a href="#">新品</a>
                                </li>
                                <li>
                                    <a href="#">评价</a>
                                </li>
                                <li>
                                    <a href="#">价格⬆</a>
                                </li>
                                <li>
                                    <a href="#">价格⬇</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="goods-list">
                        <ul class="yui3-g">
                            <li class="yui3-u-1-5" v-for="item in result" :key="item.id">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <a target="_blank">
                                            <router-link :to="`/detail/${item.id}`">
                                                <video :src="item.avatar" style="height: 200px;width: 200px" ></video>
                                            </router-link>
                                        </a>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i> {{item.price}}</i>&nbsp&nbsp
                                            <el-tag type="success" v-if="item.state === 0">已上架</el-tag>
                                            <el-tag type="danger" v-else-if="item.state === 1">已出租</el-tag>
                                            <el-tag type="info" v-else-if="item.state === 2">已过期</el-tag>
                                        </strong>
                                    </div>
                                    <div class="attr">
                                        <router-link :to="`/detail/${item.id}`">
                                            <a target="_blank" v-html="item.address+item.addressInfo+item.houseDescribe"></a>
                                        </router-link>
                                    </div>
                                    <div class="commit">
                                        <i class="command">咨询电话：<span>{{item.phoneNumber}}</span></i>
                                    </div>
                                    <div class="operate">
                                        <a href="success-cart.html" target="_blank"
                                           class="sui-btn btn-bordered btn-danger">订房</a>
                                        <a href="javascript:void(0);" class="sui-btn btn-bordered">收藏</a>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

</template>

<script>
    import {searchPage,searchHouse,searchDecorate} from '@/api/index'

    export default {
        name: "Search",
        data() {
            return {
                result: [],
                houseType:undefined,
                decorate:undefined
            }
        },
        created() {
            this.init()
        },
        methods: {
            init() {
                searchPage(this.$route.params.keyword).then(response => {
                    if (response.code==200){
                        this.result = response.data
                        // console.log(this.result)
                    }else {
                        this.$notify.error({
                            title: '错误',
                            message: response.message
                        });
                    }

                })
            },
            searchH(id){
                searchHouse(id).then(response=>{
                    if (response.code==200){
                        this.result = response.data
                        // console.log(this.result)
                    }else {
                        this.$notify.error({
                            title: '错误',
                            message: response.message
                        });
                    }
                })
            },
            searchD(id){
                searchDecorate(id).then(response=>{
                    if (response.code==200){
                        this.result = response.data
                        // console.log(this.result)
                    }else {
                        this.$notify.error({
                            title: '错误',
                            message: response.message
                        });
                    }
                })
            }
        }
    }
</script>

<style scoped lang="less">
    .selector {
        width: 1200px;
        margin-left: 160px;
        border: 1px solid #ddd;
        margin-bottom: 5px;
        overflow: hidden;

        .logo {
            border-top: 0;
            margin: 0;
            position: relative;
            overflow: hidden;

            .key {
                padding-bottom: 87px !important;
            }
        }

        .type-wrap {
            margin: 0;
            position: relative;
            border-top: 1px solid #ddd;
            overflow: hidden;

            .key {
                width: 100px;
                background: #f1f1f1;
                line-height: 26px;
                text-align: right;
                padding: 10px 10px 0 15px;
                float: left;
            }

            .value {
                overflow: hidden;
                padding: 10px 0 0 15px;
                color: #333;
                margin-left: 120px;
                padding-right: 90px;

                .logo-list {
                    li {
                        float: left;
                        border: 1px solid #e4e4e4;
                        margin: -1px -1px 0 0;
                        width: 105px;
                        height: 52px;
                        text-align: center;
                        line-height: 52px;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                        font-weight: 700;
                        color: #e1251b;
                        font-style: italic;
                        font-size: 14px;

                        img {
                            max-width: 100%;
                            vertical-align: middle;
                        }
                    }
                }

                .type-list {
                    li {
                        float: left;
                        display: block;
                        margin-right: 30px;
                        line-height: 26px;

                        a {
                            text-decoration: none;
                            color: #666;
                        }
                    }
                }
            }

            .ext {
                position: absolute;
                top: 10px;
                right: 10px;

                .sui-btn {
                    display: inline-block;
                    padding: 2px 14px;
                    box-sizing: border-box;
                    margin-bottom: 0;
                    font-size: 12px;
                    line-height: 18px;
                    text-align: center;
                    vertical-align: middle;
                    cursor: pointer;
                    padding: 0 10px;
                    background: #fff;
                    border: 1px solid #d5d5d5;
                }

                a {
                    color: #666;
                }
            }
        }
    }
    .like {
        margin-top: 15px;

        .py-container {
            width: 1200px;
            margin: 0 auto;

            .title {
                overflow: hidden;

                .fl {
                    float: left;
                    font-size: 20px;
                    line-height: 30px;
                }

                .fr {
                    float: right;
                    background-image: url(../assets/images/icons.png);
                    width: 66px;
                    height: 25px;
                    background-position: 182px -104px;
                    line-height: 30px;
                    font-size: 12px;
                    font-weight: 400;
                    color: #666;
                    text-decoration: none;
                }
            }

            .bd {
                .favourate {
                    border: 1px solid #e4e4e4;
                    overflow: hidden;
                    padding: 0 10px;
                    box-sizing: border-box;
                    display: flex;

                    li {
                        height: 250px;
                        margin: 0 -1px;
                        overflow: hidden;
                        background: #fff;
                        position: relative;
                        width: 16.667%;
                        display: flex;
                        flex-direction: column;
                        align-items: center;
                        cursor: pointer;

                        img {
                            width: 142px;
                            height: 142px;
                            transition: all 400ms;

                            &:hover {
                                opacity: 0.8;
                                transform: scale(1.1)
                            }
                        }

                        .like-text {
                            padding: 0;
                            width: 142px;
                            border-right: 1px solid #e4e4e4;

                            p {
                                margin: 5px 0;
                            }

                            h3 {
                                color: #df3033;
                                font-size: 20px;
                                line-height: 30px;
                                margin: 9px 0;
                                font-weight: 700;
                            }
                        }
                    }
                }
            }
        }
    }

    .details {
        margin-bottom: 5px;

        .sui-navbar {
            overflow: visible;
            margin-bottom: 0;

            .filter {
                min-height: 40px;
                padding-right: 20px;
                background: #fbfbfb;
                border: 1px solid #e2e2e2;
                padding-left: 0;
                border-radius: 0;
                box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);

                .sui-nav {
                    position: relative;
                    left: 0;
                    display: block;
                    float: left;
                    margin: 0 10px 0 0;

                    li {
                        float: left;
                        line-height: 18px;

                        a {
                            display: block;
                            cursor: pointer;
                            padding: 11px 15px;
                            color: #777;
                            text-decoration: none;
                        }

                        &.active {
                            a {
                                background: #e1251b;
                                color: #fff;
                            }
                        }
                    }
                }
            }
        }

        .goods-list {
            margin: 20px 0;

            ul {
                display: flex;
                flex-wrap: wrap;

                li {
                    height: 100%;
                    width: 20%;
                    margin-top: 10px;
                    line-height: 28px;

                    .list-wrap {
                        .p-img {
                            padding-left: 15px;
                            width: 215px;
                            height: 250px;

                            a {
                                color: #666;

                                img {
                                    max-width: 100%;
                                    height: auto;
                                    vertical-align: middle;
                                }
                            }
                        }

                        .price {
                            padding-left: 15px;
                            font-size: 18px;
                            color: #c81623;

                            strong {
                                font-weight: 700;

                                i {
                                    margin-left: -5px;
                                }
                            }
                        }

                        .attr {
                            padding-left: 15px;
                            width: 85%;
                            overflow: hidden;
                            margin-bottom: 8px;
                            min-height: 65px;
                            cursor: pointer;
                            line-height: 1.8;
                            display: -webkit-box;
                            -webkit-box-orient: vertical;
                            -webkit-line-clamp: 2;

                            a {
                                color: #333;
                                text-decoration: none;
                            }
                        }

                        .commit {
                            padding-left: 15px;
                            height: 22px;
                            font-size: 13px;
                            color: #a7a7a7;

                            span {
                                font-weight: 700;
                                color: #646fb0;
                            }
                        }

                        .operate {
                            padding: 12px 15px;

                            .sui-btn {
                                display: inline-block;
                                padding: 2px 14px;
                                box-sizing: border-box;
                                margin-bottom: 0;
                                font-size: 12px;
                                line-height: 18px;
                                text-align: center;
                                vertical-align: middle;
                                cursor: pointer;
                                border-radius: 0;
                                background-color: transparent;
                                margin-right: 15px;
                            }

                            .btn-bordered {
                                min-width: 85px;
                                background-color: transparent;
                                border: 1px solid #8c8c8c;
                                color: #8c8c8c;

                                &:hover {
                                    border: 1px solid #666;
                                    color: #fff !important;
                                    background-color: #666;
                                    text-decoration: none;
                                }
                            }

                            .btn-danger {
                                border: 1px solid #e1251b;
                                color: #e1251b;

                                &:hover {
                                    border: 1px solid #e1251b;
                                    background-color: #e1251b;
                                    color: white !important;
                                    text-decoration: none;
                                }
                            }
                        }
                    }
                }
            }
        }

        .page {
            width: 733px;
            height: 66px;
            overflow: hidden;
            float: right;

            .sui-pagination {
                margin: 18px 0;

                ul {
                    margin-left: 0;
                    margin-bottom: 0;
                    vertical-align: middle;
                    width: 490px;
                    float: left;

                    li {
                        line-height: 18px;
                        display: inline-block;

                        a {
                            position: relative;
                            float: left;
                            line-height: 18px;
                            text-decoration: none;
                            background-color: #fff;
                            border: 1px solid #e0e9ee;
                            margin-left: -1px;
                            font-size: 14px;
                            padding: 9px 18px;
                            color: #333;
                        }

                        &.active {
                            a {
                                background-color: #fff;
                                color: #e1251b;
                                border-color: #fff;
                                cursor: default;
                            }
                        }

                        &.prev {
                            a {
                                background-color: #fafafa;
                            }
                        }

                        &.disabled {
                            a {
                                color: #999;
                                cursor: default;
                            }
                        }

                        &.dotted {
                            span {
                                margin-left: -1px;
                                position: relative;
                                float: left;
                                line-height: 18px;
                                text-decoration: none;
                                background-color: #fff;
                                font-size: 14px;
                                border: 0;
                                padding: 9px 18px;
                                color: #333;
                            }
                        }

                        &.next {
                            a {
                                background-color: #fafafa;
                            }
                        }
                    }
                }

                div {
                    color: #333;
                    font-size: 14px;
                    float: right;
                    width: 241px;
                }
            }
        }
    }
</style>
